package com.etcn.common.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;

import com.etcn.common.dao.ICrudDao;
import com.etcn.common.pojo.BaseEntity;
import com.etcn.common.service.ICrudService;
import com.etcn.common.utils.CollectionUtil;

/**
 * service增删改查实现
 * @author guozc
 * @date 2018-01-08
 */
public class CrudServiceImpl<D extends ICrudDao<T>, T extends BaseEntity<T>> extends BaseServiceImpl
		implements ICrudService<D, T> {

	@Autowired
	protected D dao;

	@Override
	public T getById(long id) throws Exception {
		return dao.getById(id);
	}

	@Override
	public T find(T entity) throws Exception {
		return dao.find(entity);
	}

	@Override
	public List<T> findList(T entity) throws Exception {
		return dao.findList(entity);
	}
	
	@Override
	public List<T> findAppList(T entity) throws Exception {
		return dao.findAppList(entity);
	}

	@Override
	public List<T> findAllList() throws Exception {
		return dao.findAllList();
	}

	@Override
	public void insert(T entity) throws Exception {
		dao.insert(entity);
	}

	@Override
	public void insertBatch(List<T> list) throws Exception {
		if (CollectionUtil.isNotEmpty(list)) {
			dao.insertBatch(list);
		}
	}

	@Override
	public void update(T entity) throws Exception {
		dao.update(entity);
	}

	@Override
	public void updateById(T entity) throws Exception {
		dao.updateById(entity);
	}

	@Override
	public void delete(T entity) throws Exception {
		dao.delete(entity);
	}

	@Override
	public void deleteById(long id) throws Exception {
		dao.deleteById(id);
	}

	@Override
	public void deleteLogically(T entity) throws Exception {
		dao.deleteLogically(entity);
	}

	@Override
	public void deleteLogicallyById(long id) throws Exception {
		dao.deleteLogicallyById(id);
	}

}
